﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/Admin.master" AutoEventWireup="true"
    CodeFile="ViewPhieuBanHang.aspx.cs" Inherits="WebTeamplate.Admin_ViewPhieuBanHang" %>

<%@ Import Namespace="WebTeamplate" %>
<%@ Import Namespace="BusinessObject" %>
<%@ Import Namespace="Utility" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">

    <script src="../Js/BasicFunction.js"></script>

    <table class="lvtBg" border="0" cellpadding="0" cellspacing="1" width="100%">
        <tbody>
            <tr>
                <td>
                    <table border="0" style="width: 100%">
                        <td style="width: 60%" align="left" valign="top">
                            <table class="small" border="0" cellpadding="2" cellspacing="5" width="100%">
                                <tr>
                                    <td align="right" class="pnSubTitleLeft1">
                                        Cửa hàng:
                                    </td>
                                    <td class="pnSubTitleRight1">
                                        <%=CommonFunction.CompanyName%>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="pnSubTitleLeft1">
                                        Địa chỉ:
                                    </td>
                                    <td class="pnSubTitleRight1">
                                        <%=CommonFunction.CompanyAddress%>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="pnSubTitleLeft1">
                                        Điện thoại:
                                    </td>
                                    <td class="pnSubTitleRight1">
                                        <%=CommonFunction.CompanyTel%>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="pnSubTitleLeft1">
                                        Người lập phiếu:
                                    </td>
                                    <td class="pnSubTitleRight1">
                                        <%=nguoiLapPhieu %>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="pnSubTitleLeft1">
                                        Ngày lập:
                                    </td>
                                    <td class="pnSubTitleRight1">
                                        <%=ConvertValueObject.ParseString(objPhieuBanHang.NgayLapPhieu) %>
                                    </td>
                                </tr>
                            </table>
                        </td>
                        <td align="right">
                            <table border="0" style="width: 85%">
                                <tr>
                                    <td class="titleReport" colspan="2" align="right">
                                        PHIẾU BÁN HÀNG
                                    </td>
                                </tr>
                                <tr>
                                    <td align="right" class="pnSubTitleLeft">
                                        Số:
                                    </td>
                                    <td class="pnSubTitleRight">
                                        <%=this.MaSoPhieu%>
                                    </td>
                                </tr>
                                 <tr>
                                    <td align="right" class="pnSubTitleLeft">
                                        Kho:
                                    </td>
                                    <td class="pnSubTitleRight">
                                        <%=kho %>
                                    </td>
                                </tr>
                                 <tr>
                                    <td align="right" class="pnSubTitleLeft">
                                        Tình trạng:
                                    </td>
                                    <td class="pnSubTitleRight">
                                       <%if (objPhieuBanHang.IsCommit)
                                         {%>
                                            Đã chốt sổ
                                       <%}
                                         else
                                         { %>
                                            Chưa chốt sổ
                                         <%} %>
                                    </td>
                                </tr>
                                <tr>
                                    <td align="right" class="pnSubTitleLeft">
                                        Khách hàng:
                                    </td>
                                    <td class="pnSubTitleRight">
                                        <%=objKhachHang.TenKhachHang %>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="pnSubTitleLeft">
                                        Địa chỉ:
                                    </td>
                                    <td class="pnSubTitleRight">
                                        <%=objKhachHang.DiaChi %>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </table>
                </td>
            </tr>
            <tr>
                <td>
                    &nbsp;
                </td>
            </tr>
            <tr>
                <td>
                    <table class="lvt small" border="0" cellpadding="3" cellspacing="1" width="100%">
                        <!-- Table Headers -->
                        <tbody>
                            <tr>
                                <td class="lvtCol" style="width: 30px;">
                                    STT
                                </td>
                                <td class="lvtCol" style="width: 80px;">
                                    Mã mặt hàng
                                </td>
                                 <td class="lvtCol" style="width: 100px;">
                                    Mã phụ tùng
                                </td>
                                <td class="lvtCol" style="width: 240px;">
                                    Tên mặt hàng
                                </td>
                                  <td class="lvtCol" style="width: 100px;">
                                    Xe
                                </td>
                                <td class="lvtCol" style="width: 90px;">
                                    Nước SX
                                </td>
                                <td class="lvtCol" style="width: 120px;">
                                    Hiệu
                                </td>
                                <td class="lvtCol" style="width: 70px;">
                                    Số lượng
                                </td>
                                <td class="lvtCol" style="width: 70px;">
                                    Đơn vị tính
                                </td>
                                <td class="lvtCol" style="width: 140px;">
                                    Giá đơn vị
                                </td>
                                <td class="lvtCol" style="width: 140px;">
                                    Thành tiền
                                </td>
                            </tr>
                            <!-- Table Contents -->
                            <asp:Repeater ID="rptData" runat="server" OnItemDataBound="rptData_ItemDataBound">
                                <ItemTemplate>
                                    <tr class="lvtColData" onmouseover="this.className='lvtColDataHover'" onmouseout="this.className='lvtColData'"
                                        bgcolor="white">
                                        <td class="repeaterCenterData">
                                            <asp:Literal ID="ltrSTT" runat="server"></asp:Literal>
                                        </td>
                                        <td class="repeaterLeftData">
                                            <%# Server.HtmlEncode(Eval("MaMatHang").ToString())%>
                                        </td>
                                         <td class="repeaterLeftData">
                                            <%# Server.HtmlEncode(Eval("MaPhuTung").ToString())%>
                                        </td>
                                        <td class="repeaterLeftData">
                                            <%# Server.HtmlEncode(Eval("TenMatHang").ToString())%>
                                        </td>
                                         <td class="repeaterLeftData">
                                            <%#GetXe(Eval("MaXe").ToString())%>
                                        </td>
                                        <td class="repeaterLeftData">
                                            <%# Server.HtmlEncode(Eval("NuocSX").ToString())%>
                                        </td>
                                        <td class="repeaterLeftData">
                                            <%# Server.HtmlEncode(Eval("Hieu").ToString())%>
                                        </td>
                                        <td class="repeaterRightData">
                                            <%#Eval("SoLuongBan")%>
                                        </td>
                                        <td class="repeaterLeftData">
                                            <%# Server.HtmlEncode(Eval("DonViTinh").ToString())%>
                                        </td>
                                        <td class="repeaterRightData">
                                            <asp:Literal ID="ltrGia" runat="server"></asp:Literal>
                                        </td>
                                        <td class="repeaterRightData">
                                            <asp:Literal ID="ltrThanhTien" runat="server"></asp:Literal>
                                        </td>
                                    </tr>
                                </ItemTemplate>
                                <FooterTemplate>
                                    <tr class="lvtColData">
                                        <td colspan="10" class="repeaterRightData">
                                            Thành tiền
                                        </td>
                                        <td class="repeaterRightData">
                                            <asp:Literal ID="ltrTotal" runat="server"> </asp:Literal>
                                        </td>
                                    </tr>
                                    <%if (objPhieuBanHang.IsVAT)
                                      { %>
                                       <tr class="lvtColData">
                                        <td colspan="10" class="repeaterRightData">
                                            VAT
                                        </td>
                                        <td class="repeaterRightData">
                                            <%=objPhieuBanHang.VAT  %>%
                                        </td>
                                    </tr>
                                    <tr class="lvtColData">
                                        <td colspan="10" class="repeaterRightData">
                                            Cộng thành tiền
                                        </td>
                                        <td class="repeaterRightData">
                                            <asp:Literal ID="ltrTotalVAT" runat="server"> </asp:Literal>
                                        </td>
                                    </tr>
                                    <%} %>
                                </FooterTemplate>
                            </asp:Repeater>
                        </tbody>
                    </table>
                </td>
            </tr>
           
                <tr class="rowDetail">
                    <td>
                       <b> Cộng thành tiền(bằng chữ): &nbsp;</b>
                        <span class="textCurency">
                        <asp:Literal ID="ltrTotalString" runat="server"> Một triệu hai trăn ngàn đồng </asp:Literal>
                        </span>
                    </td>
                </tr>
                <tr class="rowDetail" align="right">
                    <td align="center">
                        <asp:Button ID="btnEdit" runat="server" Text="Cập nhật" Width="70px" OnClick="btnEdit_Click"
                            CssClass="crmbutton 
small edit" />
                        <asp:Button ID="btnExportExcel" runat="server" Text="Xuất Excel" Width="100px" Visible="false"
                            OnClick="btnExportExcel_Click" CssClass="crmbutton 
small edit" />
                        <asp:Button ID="btnPrint" runat="server" Text="In" Width="70px" OnClientClick="return PrintView();"
                            CssClass="crmbutton 
small edit" />
                        <asp:Button ID="btnCancel" runat="server" Text="Bỏ qua" Width="80px" OnClick="btnCancel_Click"
                            CssClass="crmbutton 
small edit" />
                    </td>
                </tr>
        </tbody>
    </table>

    <script type="text/javascript">
        function PrintView() {
            var id = <%=MaPhieuBan %>;
            popImg(id);
            return false;
        }
        function popImg(id) {
            var w = 930;
            var h = 680;
            var wleft = (screen.width - w) / 2;
            var wtop = (screen.height - h) / 2;
            // IE5 and other old browsers might allow a window that is
            // partially offscreen or wider than the screen. Fix that.
            // (Newer browsers fix this for us, but let's be thorough.)
            if (wleft < 0) {
                w = screen.width;
                wleft = 0;
            }
            if (wtop < 0) {
                h = screen.height;
                wtop = 0;
            }
            var pURL = 'PopupPrintPhieuBanHang.aspx?id=' + id;
            //var pURL='map.html';
            pInfo = 'toolbar=1,';
            pInfo += 'location=0,';
            pInfo += 'directories=0,';
            pInfo += 'status=0,';
            pInfo += 'menubar=1,';
            pInfo += 'scrollbars=1,';
            pInfo += 'resizable=1,';
            pInfo += 'width=' + w + 'px,';
            pInfo += 'height=' + h + 'px,';
            pInfo += 'left=' + wleft + ',';
            pInfo += 'top=' + wtop + ',';
            pInfo += 'text-align:center';
            //alert(pInfo);
            window.open(pURL, 'BarCode', pInfo, true);
        }
    </script>

</asp:Content>
